package tests;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import rss.News;
/**
 * 
 * @author Igor
 *Tests of News class.
 */
public class NewsTest {

	private News news;
	
	
	@Before
	public void createNews()throws Exception{
		
		news = new News("http://rss.terra.com.br/0,,EI1137,00.xml");
	}
	
	@Test(expected=Exception.class)
	public void createNewsNullUrl()throws Exception{
		news = new News(null);
	}
	@Test(expected=Exception.class)
	public void createNewsFailed()throws Exception{
		news = new News("www.google.com");
	}
	
	@Test
	public void newsConstructor()throws Exception{
		Assert.assertEquals("Wrong RSS", news.getRss(),"http://rss.terra.com.br/0,,EI1137,00.xml" );
		Assert.assertEquals("Wrong Size", news.getAllNews().size(), 30);
		Assert.assertFalse("Able to Update", news.updateNews());
		Assert.assertEquals("Wrong Title Feed", news.getFeedTitle(), "Terra - RSS - Esportes");
	}
	
	
	
}
